package com.poet.df.service;

import java.io.Serializable;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.poet.df.dao.BaseDao;
import com.poet.df.entity.Form;
import com.poet.df.entity.FormLine;

@Service
public class DynamicFormService {

	@Resource
	private BaseDao baseDao;
	
	public List<Form> getAllForms(){
		return baseDao.findAll(Form.class);
	}
	
	public boolean saveForm(Form form){
		Serializable id = baseDao.save(form);
		return id != null;
	}
	
	public List<FormLine> getFormLinesById(Serializable id){
		String hql = "from FormLine f where f.form.id = ?";
		return baseDao.find(hql, id);
	}
}
